package com.example.controller;

import com.example.entity.In_out;
import com.example.service.In_outService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/In_out")
public class In_outController {
    @Autowired
    private In_outService in_outService;


    @PostMapping
    public Map<String, Object> save(@RequestBody In_out in_out) {
        return in_outService.saveIn_ot(in_out);
    }

//    @DeleteMapping("/delete")
//    public Map<String, Object> deleteByStuNum(@RequestParam Integer id) {
//        return in_outService.deleteByIn_otId(id);
//    }

    @GetMapping("/page")
    public Map<String, Object> findIn_otPage(@RequestParam Integer pageNum,
                                             @RequestParam Integer pageSize,
                                             @RequestParam String floor_num) {
        pageNum = (pageNum - 1) * pageSize;
        List<In_out> data = in_outService.selectPage(pageNum, pageSize, floor_num);
        Integer total = in_outService.selectTotal(floor_num);
        Map<String, Object> res = new HashMap<>();
        res.put("data", data);
        res.put("total", total);
        return res;
    }
}
